/*
 * Copyright: Copyright (c)2011
 * Company: 易宝支付(YeePay)
 */

package com.cyl.yeepay.gateway.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cyl.manager.yee.service.YeeMerchantService;
import com.cyl.manager.yee.service.YeeMerchantSifService;
import com.cyl.yeepay.config.YeePayConfig;
import com.cyl.yeepay.vo.RegxwNotifyRetVo;
import com.yeepay.yop.sdk.service.common.callback.YopCallback;

import cn.hutool.json.JSONUtil;

/**
 * 小微注册成功后，易宝将商户请求流水号及对应的商户编号返回到此地址
 * 
 */
@Component
public class YopRegXwCallbackHandler extends YopBaseCallbackHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(YopRegXwCallbackHandler.class);

    @Autowired
    private YeePayConfig yeePayConfig;
    
    @Autowired
    private YeeMerchantService yeeMerchantService;
    
    @Override
    public String getType() {
        return "/regxw/notify";
    }

    @Override
    public void handle(YopCallback callback) {
    	  String json = callback.getBizData();
    	  LOGGER.info("/regxw/notify :" + json);
    	  RegxwNotifyRetVo regxwNotifyRetVo = JSONUtil.toBean(json, RegxwNotifyRetVo.class);
    	  yeeMerchantService.notify(regxwNotifyRetVo,json);   
    }
}